package model;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class InventoryList implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7250686063467042762L;
	private Map<String, Item> list;
	
	/*
	 * constructors
	 */
	public InventoryList(){
		list = new HashMap<String, Item>();
	}
	
	/**
	 * overridden map methods
	 */

	
	public void clear() {
		list.clear();	
	}

	
	public boolean containsKey(String arg0) {
		return list.containsKey(arg0);
	}

	
	public boolean containsValue(String arg0) {
		return list.containsValue(arg0);
	}

	
	public Set<Map.Entry<String, Item>> entrySet() {
		return list.entrySet();
	}

	
	public Item get(String arg0) {
		return list.get(arg0);
	}

	
	public boolean isEmpty() {
		return list.isEmpty();
	}

	
	public Set<String> keySet() {
		return list.keySet();
	}

	
	public Item put(String arg0, Item arg1) {
		return list.put(arg0, arg1);
	}

	
	public void putAll(Map<String, Item> arg0) {
		list.putAll(arg0);
	}

	
	public Item remove(String arg0) {
		return list.remove(arg0);
	}

	
	public int size() {
		return list.size();
	}

	
	public Collection<Item> values() {
		return list.values();
	}
	
	/**
	 * inventory specific methods
	 */
	
	/**
	 * addStock
	 * @param an item id
	 * @param the quantity of items to add
	 * @return boolean
	 * description: Attempts to add the specified value to the
	 * given item's quantity. If the item does not yet exist
	 * in the map, the method returns false.
	 */
	public boolean addStock(String id, int quantity){
		Item item = list.get(id);
		
		if(item == null) return false;
		else{
			item.setQuantity(quantity);
			list.put(id, item);
			return true;
		}
	}
	
}